Fix: rootCoverageReport ignores androidTests coverage results when executeAndroidTests is false #104
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
In our project we are using gradle managed devices to execute ui tests. Ui tests launch configuration is a bit complicated in our use case, so I had to launch ui tests separately from
Android-Root-Coverage-Plugin. And then after ui tests have finished it's execution, I am using:rootCoverageReport"The problem here, is that coverage results from ui tests are being ignored by:rootCoverageReport. This happens only with gradle managed devices, if I manually execute ui tests on connected emulator, and than use:rootCoverageReportto create aggregated coverage report, everything works as expected.I have created new configuration
gradle-managed-device-dont-execute-android-tests.yamlforIntegrationTest.kt, that reproduces the issue above.Solution
This pull request also contains fix of that problem. Here are key components of the fix:
includeGradleManagedDevicesResults = false, in case ofexecuteAndroidTestsis false. Now that is fixed.project.tasks.findByPath("$path:allDevices${name}AndroidTest")tosubProject.tasks.configureEachinsideJacocoReport.addSubProjectVariant.project.tasks.findByPathwas always returing null, because task$path:allDevices${name}AndroidTestwasn't configured yet at the timeproject.tasks.findByPathis called.